package com.creditdnepr.freebank.ui;

import android.app.Dialog;
import android.os.Bundle;
import android.sax.TextElementListener;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.creditdnepr.freebank.R;

public class LoginActivity extends BaseActivity {

	   @Override
	   protected Dialog onCreateDialog(int id) {
	      switch (id) {
	      case 1:
	         Dialog dialog = new Dialog(this);
	         dialog.setContentView(R.layout.forgott_pass_dialog);
	         dialog.setTitle(getString(R.string.app_name));
	         return dialog;
	      }
	      return null;
	   }
	
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login_form);
		getActivityHelper().setupActionBar(
				getString(R.string.ui_freebank_enter), 0);

		TextView v = (TextView) findViewById(R.id.labelForgottPass);
		v.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				showDialog(1);
			}
		});
		
		EditText e = (EditText)findViewById(R.id.eLogin);
		e.setOnFocusChangeListener(new OnFocusChangeListener() {
			public void onFocusChange(View v, boolean hasFocus) {
				Log.i("FreeBank", "onFocusChanged");
			}
		});
		e.setOnEditorActionListener(new OnEditorActionListener() {
			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
				if (event.getKeyCode()==66) {
					v.focusSearch(View.FOCUS_DOWN);
				}
				return false;
			}
		});
		
		Button b = (Button)findViewById(R.id.ButtonEnter);
		b.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				setResult(RESULT_OK);				
				finish();
			}
		});

	}

}
